package net.neptech.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import lombok.Data;
import net.neptech.feign.ScheduleFeignClient;
import net.neptech.model.appointment.ClnicStaff;
import net.neptech.model.dto.ClnicStaffDTO;
import net.neptech.model.schedule.ScheShift;
import net.neptech.model.schedule.Schedule;
import net.neptech.model.vo.ClnicStaffVo;
import net.neptech.model.vo.ScheduleToClnic;
import net.neptech.service.IClnicStaffService;
import net.neptech.service.IScheduleToClnicService;
import net.neptech.service.impl.IClnicStaffServiceImpl;
import net.neptech.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@Tag(name = "坐诊号池相关")
public class ClnicStaffController {

    private final IClnicStaffService clinicStaffService;
    private final IScheduleToClnicService scheduleToClnicService;
    public ClnicStaffController(
            IClnicStaffService clinicStaffService,
            IScheduleToClnicService scheduleToClnicService) {
        this.scheduleToClnicService = scheduleToClnicService;
        this.clinicStaffService = clinicStaffService;
    }
    /**
     * 根据医生id查询坐诊号
     * @return
     */
    @GetMapping(value = "/clinicStaffStaffId")
    @Operation(summary = "根据医生id查询坐诊号")
    public ResponseResult<List<ClnicStaffVo>> getClnicStaffByStaffId(
                     @RequestParam("staffId") String staffId
                    ,@RequestParam("typeId") Integer typeId) {

        return clinicStaffService.getClinicStaffListByWeek(staffId,typeId);

    }
    /**
     * 更新号池
     * @param num 更新未来几天的
     * @return
     */
    @GetMapping(value = "/putslots")
    @Operation(summary = "更新号源")
    public ResponseResult<Boolean> putSlots(
                    @RequestParam("num") Integer num) {
        return clinicStaffService.putRedis(num);

    }

    /**
     * 根据日期查询该科室坐诊医生详细信息
     * @param staffDTO
     * @return
     */
    @PostMapping(value = "/getClinicStaff")
    @Operation(summary = "根据日期查该科室坐诊医生详细信息")
    public ResponseResult<List<ClnicStaffVo>> getClinicStaffListByDate(
            @RequestBody ClnicStaffDTO staffDTO) {
        Long deptId = staffDTO.getDeptId();
        Date clnicTime = staffDTO.getClnicTime();
        Byte typeId = staffDTO.getTypeId();
        //
        return clinicStaffService.getClinicStaffListByDate(clnicTime, deptId, typeId);
    }
//    @Autowired
//    private ScheduleFeignClient feignClient;

    @GetMapping(value = "/testStoC")
    public ResponseResult<List<ClnicStaff>> testOpenFeign() {
        List<ClnicStaff> convert = scheduleToClnicService.convert();
        return ResponseResult.success(convert);
    }

    @GetMapping(value = "/testStocByDay")
    public ResponseResult<List<ClnicStaff>> testOpenFeign(
            @RequestParam("dayNum") Integer day) {
        List<ClnicStaff> convert = scheduleToClnicService.timeConvert(day);
        return ResponseResult.success(convert);
    }


    @GetMapping(value = "/getCurrentClicStaff")
    public ResponseResult<List<ClnicStaffVo>> getCurrentClicStaff(@RequestParam("staffId") Long staffId) {
        List<ClnicStaffVo> clnicStaff = clinicStaffService.getClnicStaff(staffId);
        return ResponseResult.success(clnicStaff);
    }

    @GetMapping(value = "/inset/{dayNum}")
    @Operation(summary = "根据排班信息插入坐诊数据")
    public ResponseResult<List<ClnicStaff>> insetClinicStaff(@PathVariable("dayNum") Integer dayNum) {
        List<ClnicStaff> convert = scheduleToClnicService.timeConvertByDayNum(dayNum);
        return ResponseResult.success(convert);
    }

    
    




}
